
function gt() {
	var d = new Date();
	return(""+d.getYear()+d.getMonth()+d.getDay()+d.getHours()+d.getMinutes()+d.getSeconds()+d.getUTCMilliseconds());
}
var wh;
function w(u,n,w,h,scrl){
	if (u.indexOf("?",0) == -1)
		u = u + "?time=";
	else
		u = u + "&time=";
	u = u + gt();
	wh = open(u,n,"width=" + w + ",height=" + h + ",stats=no,titlebar=no,location=no,toolbar=no,scrollbars=" + scrl + ",resizeable=no");
	wh.focus();
}



function pickitem(userid, mapid, itemid) {
	$.post("pickitem.action", {
		userid: userid,
		mapid: mapid,
		itemid: itemid
    },
    function(json) {
        var messages = json.message.split("#");
        if ("pickupok" == messages[0]) {
            alert("拾取成功！");
            $('#item_' + messages[1]).remove();
        } else if ("usernull" == messages[0]) {
            alert("用户非法！");
        } else if ("noitem" == messages[0]) {
            alert("道具不存在！");
            $('#item_' + messages[1]).remove();
        } else if ("fullitem" == messages[0]) {
            alert("背包已满，无法拾取道具！");
            //不用删除吧？
            //$('#item_' + messages[1]).remove();
        } else {
            alert(json.message);
        }
    });
	
}
function displaynpc(npcdesc) {
	npcdesc.style.display = "block";
}
function covernpc(npcdesc) {
	npcdesc.style.display = "none";
}


var inTable = false; 
var inDiv = false; 

var IsIE=!!document.all;
//下面这个是对firefox进行扩展的
if(!IsIE) {
	HTMLElement.prototype.contains=function(o){
	  while(o!=null){
	    if(o==this)return true;
	    o=o.parentNode;
	  }
	  return false;
	};
}
function showDiv(npcdesc) 
{ 
inTable = true; 
npcdesc.style.display = "block";
} 
//当鼠标移动到目标div的子元素上时，会触发子元素的mouseoverDiv方法，设置inDiv = true，这样延迟后的判断条件就不成立，从而继续显示了。
function hiddenDiv(npcdesc) 
{
	inTable = false; 
	//setTimeout("hiddenDivTimeOut("+npcdesc+")",100);
	if(inTable == false && inDiv == false) {
		setTimeout(function() {
			if(inTable == false && inDiv == false) 
			{ 
				npcdesc.style.display = "none";
			} 
		}, 100);
	}
}

function mouseoverDiv() 
{ 
	inDiv = true; 
} 
function mouseoutDiv(npcdesc,e) 
{
	e=e||event;
	var obj=e.relatedTarget||e.toElement;
	if(npcdesc.contains(obj))return;
	inDiv = false; 
	if(inTable == false && inDiv == false) 
	{ 
		npcdesc.style.display = "none";
	}
}
function hiddenThis(npcdesc) {
	npcdesc.style.display = "none";
}
function talkshow(npcid) {
    document.getElementById("talkshowdetail").innerText = "";
	document.getElementById("npcdesc_"+npcid).style.display = "none";
	document.getElementById("talkshow").style.display = "block";
	//document.getElementById("talkshowdetail").innerText = "sssaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
	$.get(ctxf+"/fantasy/npc/talktoNpc2", {
		npcId: npcid
    },
    function(json) {
        var messages = json.message;
        document.getElementById("talkshowdetail").innerText = "  " + messages;
    });
}
function hiddentalkshow() {
	document.getElementById("talkshow").style.display = "none";
}
